﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace A.HTMlServer.HThread
{
    public class RunThread
    {
        object objState = new object();
        ToThread.ToHtmlDelegate Hdelegate;
        public RunThread()
        {
 
        }

        public void Start(ToThread.ToHtmlDelegate DT)
        {
            Hdelegate=DT;
            Thread Th = new Thread(ThreadRun);
            Th.Start();
        }

        #region 线程操作
        private void ThreadRun()
        {
            string strUrl = null;
            do
            {
                //Hdelegate("123");
                lock (ToThread.ObjLock)
                {
                    if (ToThread.Llink.Count > 0)
                    {
                        strUrl = ToThread.Llink[0];
                        ToThread.Llink.RemoveAt(0);
                    }
                }
                if(strUrl!=null)
                {
                    Hdelegate(strUrl);
                    strUrl=null;
                }
                Thread.Sleep(500);
            } while (true);
        }
        #endregion
    }
}
